package com.yzg.design;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @author misterWei
 * @create 2020年05月15号:23点57分
 * @mailbox forcontinue@163.com
 */
@Slf4j(topic = "c.parkUnparkOrderOut")
public class ParkUnparkOrderOut {
    static boolean flag = false;
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while (!flag) {
                LockSupport.park();
            }
            log.debug("2");

        }, "t1");
        t1.start();
        TimeUnit.SECONDS.sleep(3L);
        new Thread(()->{
            LockSupport.unpark(t1);
                flag = true;
                log.debug("1");
        },"t2").start();

    }



}
